package com.fkcai.hansoul.config;

import com.fkcai.hansoul.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义 Web 相关配置（如拦截器注册、静态资源映射等）。
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
	
	@Override
	public void addInterceptors (InterceptorRegistry registry) {
		// 拦截所有用户相关接口，除了登录和注册
		registry.addInterceptor(new LoginInterceptor())
				.addPathPatterns("/api/**")
				.excludePathPatterns(
						"/api/user/register",
						"/api/user/login",
						"/api/user/updatePassword",
						"/api/user/forgetPassword",
						"/api/category/postCategories",
						"/api/posts/exclude/**",
						"/druid/**"
						
				);
	}
}
